﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OnlineAuction.TemplateMaster
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        
        protected void Buttonsubmit_Click(object sender, EventArgs e)
        {
            if (!this.accept.Checked)
                this.message.InnerText = "Chon accept";
            else
            {
                OnlineAuctionDataContext tkdc = new OnlineAuctionDataContext();
                var kt = tkdc.Accounts.Where(tk => tk.Equals(this.username.Value)).Count();
                if (kt == 1)
                    this.message.InnerText = "Tai Khoan da ton tai";
                else
                {
                    Account tk = new Account();
                    tk.username = this.username.Value;
                    tk.password = this.password.Value;
                    tk.fullname = this.fullname.Value;
                    tk.address = this.address.Value;
                    tk.email = this.email.Value;
                    tk.phone = this.phone.Value;

                    tkdc.Accounts.InsertOnSubmit(tk);
                    tkdc.SubmitChanges();
                }
            }
        }
    }
}